package chater05;

import junit.framework.TestCase;

public class TestGeneratePrimes extends TestCase {
    private GeneratePrimes generatePrimes = null;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        generatePrimes = new GeneratePrimes();
    }

    @Override
    protected void tearDown() throws Exception {
        generatePrimes = null;
        super.tearDown();
    }

    public void testGeneratePrimes1() {
        generatePrimes = new GeneratePrimes();
        /** @todo fill in the test code */
    }

    public void testGeneratePrimes() {
        // --------------
        int[] nullArray = generatePrimes.generatePrimes(0);
        assertEquals(nullArray.length, 0);
        // 測試 <=2 的質數, 應該只有2
        int[] minArray = generatePrimes.generatePrimes(2);
        assertEquals(minArray.length, 1);
        assertEquals(minArray[0], 2);
        // 測試 <=3 的質數, 應該有2個分別是 2和3
        int[] threeArray = generatePrimes.generatePrimes(3);
        assertEquals(threeArray.length, 2);
        assertEquals(threeArray[0], 2);
        assertEquals(threeArray[1], 3);
        // 測試 <=100 的質數, 應該有25個, 最後一個是 97
        int[] centArray = generatePrimes.generatePrimes(100);
        assertEquals(centArray.length, 25);
        assertEquals(centArray[24], 97);
        // --------------
        /*
         * int maxValue = 0; int[] expectedReturn = null; int[] actualReturn = generatePrimes.generatePrimes(maxValue);
         * assertEquals("return value", expectedReturn, actualReturn);
         */
    }

}